<?php
require_once('includes.php');

/*
 * Vehicle class
 */

class Vehicle {

  public $db;

  public function __construct() {
    $this->db = new Database();

  }

  public function display_year() {
    $result = $this->db->get_year();
    while ($tier = mysql_fetch_array($result)) {
      echo '<option value="' . $tier['modelYear'] . '">' . $tier['modelYear'] . '</option>';
    }
  }

  public function display_makers($year) {
    $result = $this->db->get_maker($year);
    echo '<select name="drop_2" id="drop_2">
  	      <option value=" " disabled="disabled" selected="selected">Choose Maker</option>';

    while ($drop_2 = mysql_fetch_array($result)) {
      echo '<option value="' . $drop_2['mfrName'] . '">' . $drop_2['mfrName'] . '</option>';
    }

    echo '</select>';
    echo "<script type='text/javascript' src='js/script.js' ></script>";
  }

  public function display_models($year, $maker) {
    $result = $this->db->get_models($year, $maker);
    echo '<select name="drop_3" id="drop_3">
  	      <option value=" " disabled="disabled" selected="selected">Choose Model</option>';

    while ($drop_3 = mysql_fetch_array($result)) {
      echo '<option value="' . $drop_3['carline'] . '">' . $drop_3['carline'] . '</option>';
    }

    echo '</select> ';
    echo "<script type='text/javascript' src='js/script.js' ></script>";
  }

  public function display_transmission($year, $maker,$model) {
    $result = $this->db->get_vehicle_transmission($year, $maker,$model);
    echo '<select required name="drop_4" id="drop_4" >
  	      <option value=" " disabled="disabled" selected="selected">Choose Transmission</option>';

    while ($drop_4 = mysql_fetch_array($result)) {
      echo '<option value="' . $drop_4['transmission'] . '">' . $drop_4['transmission'] . '</option>';
    }

    echo '</select> ';
    echo "<script type='text/javascript' src='js/script.js' ></script>";

  }

  public function display_button() {
    echo '<input class="submit" type="submit" name="submit" value="Submit" />';
  }
}